import { ref, reactive } from 'vue'
function useModule() {
  let count = ref(5)
  let states = reactive({
    formObj: {
      name: '',
      age: '',
    },
    list: [
      { name: 'zqf', age: 12 },
      { name: 'wangwu', age: 13 },
      { name: 'lisi', age: 14 },
    ],
  })
  function remove(name) {
    states.list = states.list.filter((item) => item.name !== name)
  }
  function addItem() {
    let { name, age } = states.formObj
    states.list.push({ name, age })
    states.formObj = { name: '', age: '' }
  }
  function changeCount() {
    console.log(count)
    count.value = count.value + 1
  }
  return { count, states, remove, addItem, changeCount }
}
export default useModule
